<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>修改密码</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
    <link href="/resource/css/table.css" rel="stylesheet" type="text/css">
</head>
<body class="childrenBody">
<div class="book_con01">
    <div class="layui-form layui-row changePwd">
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input th:value="${user.userName}" name="userName" type="text" value="" disabled=""
                           class="layui-input layui-disabled"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input id="oldPwd" name="oldPas" type="password" value="" placeholder="请输入旧密码"
                           lay-verify="required"
                           class="layui-input pwd"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input id="newPwd" type="password" value="" placeholder="请输入新密码" lay-verify="required"
                           name="newPas" class="layui-input pwd"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" id="confirmPwd" value="" placeholder="请确认密码" lay-verify="required"
                           class="layui-input pwd"/>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="" lay-submit="" lay-filter="changePwd">立即修改</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">


    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form
        form.on('submit(changePwd)', function (data) {
            if ($("#confirmPwd").val() != $("#newPwd").val()) {
                layer.msg("两次密码输入不一致!");
                return false;
            }
            $.ajax({
                url: '/updatePas',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        $("#oldPwd").val("");
                        $("#newPwd").val("");
                        $("#confirmPwd").val("");
                        layer.msg("设置成功!");
                    } else {
                        layer.msg(result.msg);
                    }
                    form.render();
                }

            });
        });
    });

</script>

</body>
</html>